# Contributor: Damian Kurek <starfire24680@gmail.com>
# Maintainer: Damian Kurek <starfire24680@gmail.com>
pkgname=kodi-game-libretro-beetle-saturn
pkgver=1.29.0.40
_realname=Nexus
pkgrel=0
pkgdesc="Beetle-Saturn for Kodi"
options="!check" # no test suite
url="https://github.com/kodi-game/game.libretro.beetle-saturn"
arch="x86_64 aarch64 armv7" # kodi is available only on these architectures
license="GPL-2.0-only"
makedepends="cmake kodi-dev samurai"
depends="kodi-game-libretro libretro-beetle-saturn"
source="$pkgname-$pkgver-$_realname.tar.gz::https://github.com/kodi-game/game.libretro.beetle-saturn/archive/$pkgver-$_realname.tar.gz"
builddir="$srcdir/game.libretro.beetle-saturn-$pkgver-$_realname"

build() {
	cmake -B build -G Ninja \
		-DCMAKE_BUILD_TYPE=None \
		-DCMAKE_INSTALL_PREFIX=/usr \
		-DCMAKE_MODULE_PATH=/usr/lib/cmake/kodi
	cmake --build build
}

package() {
	DESTDIR="$pkgdir" cmake --install build
	rm -r "$pkgdir"/usr/share/kodi/addons/game.libretro.beetle-saturn/resources/icon.png \
		"$pkgdir"/usr/lib/kodi/addons/game.libretro.beetle-saturn/game.libretro.beetle-saturn.so
	ln -s /usr/lib/libretro/mednafen_saturn_libretro.so \
		"$pkgdir"/usr/lib/kodi/addons/game.libretro.beetle-saturn/game.libretro.beetle-saturn.so
	sed -i '/<assets>/,/<\/assets>/d' "$pkgdir"/usr/share/kodi/addons/game.libretro.beetle-saturn/addon.xml
}

sha512sums="
20476e6cec3c239eb3024612ba46886176b1fc1c3c97cd09579948d2f7cbf3906c97a5957e0fc0c8e79c05c045d8faec5309e59243eb19eca05be6a577996873  kodi-game-libretro-beetle-saturn-1.29.0.40-Nexus.tar.gz
"
